<style>
	.label {
		border-radius: 3px 3px 3px 3px;
	}
	.label{
		background-color: #999999;
		color: #FFFFFF;
		display: inline-block;
		font-size: 11.844px;
		font-weight: bold;
		line-height: 14px;
		padding: 2px 4px;
		text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
		vertical-align: baseline;
		white-space: nowrap;
	}
	.label-success{
		background-color: #468847;
	}
	.label-error{
		background-color: #cc0033;
	}
	.assignto-list,.copyto-list{max-width:410px}
	.assignto-list span,.copyto-list span{margin:5px 6px;position:relative;cursor:pointer}
	.assignto-list span i,.copyto-list span i{position:absolute;left:95%;color:#468847;cursor:pointer;display:none;top:65%;}
	.load{width:11px;height:11px;display:block;position:absolute;left:101%;background:url(__STATIC__/images/load.gif);top:20%}
</style>
<!-- 移动到基础里的元素 -->
<div id="move-base">
	<div class="form-item cf" sort="{$field['dateline']}">
		<label class="item-label">指派给<span class="check-tips">（将任务指派给某人，输入‘@’+对方‘名字’。）</span></label>
		<div class="controls">
			<div class="assignto-list"></div>
			<input type="text" id="assignto" class="text input-large" data-name="assignto" value="{$info.dateline}" oninput="stringToName($(this))" onblur="stringToName($(this),1)" request-url = "{:U('User/getUserByName')}"/>
		</div>
	</div>
	<div class="form-item cf" sort="{$field['dateline']}">
		<label class="item-label">抄送给<span class="check-tips">（抄送给某人，可以让某人看到该项任务。）</span></label>
		<div class="controls">		
			<div class="copyto-list"></div>
			<input type="text" id="copyto" class="text input-large" data-name="copyto" oninput="stringToName($(this))" onblur="stringToName($(this),1)" request-url = "{:U('User/getUserByName')}"/>
		</div>
	</div>
	<!----如果是工作计划，有截止时间--->
	<div class="form-item cf" sort="{$field['dateline']}">
		<label class="item-label">截止时间<span class="check-tips">（格式: yyyy-mm-dd hh:ii）</span></label>
		<div class="controls">
			<input id="dateline" type="text" class="text input-large" name="dateline" value="{$info.dateline}" />
		</div>
	</div>
	<div class="form-item cf" sort="{$field['content']}">
		<label class="item-label">详细内容</label>
		<div class="controls">
			<label class="textarea">
				<textarea name="content" id="content">{$info.content}</textarea>
				{:hook('adminArticleEdit', array('name'=>'content','value'=>$content))}
			</label>
		</div>
	</div>
</div>
			
<!-- 移动到高级里的元素 -->
<div id="move-advance"></div>
<script>
	var user = [];
	function toList(target){
		target.find('i').click(function(){
			
			$(this).parent().remove();
		});
		target.find('span').hover(function(){
			$(this).find('i').show();
		},function(){
			$(this).find('i').hide();
		});
	}
	function stringToName(obj,type){
		var target = obj.prev();
		var str = obj.val().split('@');
		var name = obj.attr('data-name');
		if(type || str.length >= 3){
			
			var span = '';
			str.shift();
			str.forEach(function(i){
				if(i != ""){
					if($.inArray(i,user) > -1){
						obj.css('border','2px solid  #cc0066').val('@');
						return;
					}
					var url = obj.attr('request-url');
					$.getJSON(url,{name:i},function(json){
						if(json.status == 1){
							span += '<span class="label label-success"><input type="hidden" name="'+name+'[]" value="'+json.data+'" />'+i+'<i class="icon-remove-sign"></i></span>';
							target.append(span);
							target.find('span').on('click',toList(target)).trigger('click');
							obj.css('border','none');
							obj.val('@');
							user.push(i);
						}else{
							obj.css('border','2px solid  #cc0066').val('@'+i);
						}
					});
					
				}
			});
			
		}
	}
</script>

